' Donut.txt b+ 2021-03-17
' attempt #2 to do a fun little graphic

' center screen for circles
cx = d[xmax,2]
cy = d[ymax,2]
' area needed = number of chars we want to layover donut in pixels
' get Donut.txt file loaded as file (AString with Chr$(1) delimiters) and count chars.
file = load[Donut.txt]
LenF = len[file]
' fiddle the multiplier until everything just fits
areaNeeded = x[8,16,lenF,1.09]
' area of circle pi r^2  Big area Needed = hole area + areaNeeded, so big Radius = sqr(that/pi)  
smallRadius = d[cy,3]
holeArea = x[p[smallRadius,2],pi[1]]
bigRadius = sqr[d[a[holeArea,areaNeeded],pi[1]]] 
midRadius = d[a[smallRadius,bigRadius],2]
rad = smallRadius
[
	if lt[rad,midRadius]
		brownInkFrac = s[1,d[s[midRadius,rad],s[midRadius,smallRadius]]]
		gs BrownInk\
	el
		brownInkFrac = d[s[bigRadius,rad],s[bigRadius,midRadius]]
		gs BrownInk\
	fi
	circ cx;cy;rad
	rad = a[rad,.25]
	jmp gt[rad,bigradius]
]
' transparent background
paper 0;0;0;0
fixSmallRad = a[smallRadius,8]
fixBigRad = s[bigRadius,8]
y = 8
i = 0
[
	x = 4
	[
		' is x,y inside donut
		d = sqr[a[p[s[x,cx],2],p[s[y,cy],2]]]
		if gt[d,fixSmallRad]
			if lt[d,fixBigRad]
				'draw char
				ink rnd[255];rnd[255];rnd[255]
				i = a[i,1]
				tag s[x,4];s[y,8];mid1[file,i]
			fi
		fi
		x = a[x,8]
		jmp gt[x,xmax]
	]
	y = a[y,16]
	jmp gt[y,ymax]
]
' restore oh colors
paper 0;0;39
ink 100;180;225
tag a[cx,s[bigRadius,50]];a[cy,s[bigRadius,50]];h
end
' according to brownInkFrac ink (color fore, ) a shade of brown
BrownInk\
' 180, 90, 55,    80, 40, 20
  brownInkRed = a[80,x[100,brownInkFrac]]
  brownInkGrn = a[40,x[50,brownInkFrac]]
  brownInkBlu = a[20,x[35,brownInkFrac]]
  ink brownInkRed;brownInkGrn;brownInkBlu
rtn